package com.kingt.social.storage;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;


/**
 * @author xiaoguang.he
 * @time 2012-07-27
 */
public class ValueStorage {
	private SharedPreferences sharedPreferences;
	private Editor editer;
	
	public ValueStorage(Context c){
		sharedPreferences = c.getSharedPreferences(c.getPackageName(), Context.MODE_PRIVATE);
		editer = sharedPreferences.edit();
	}
	
	public void putValue(String key, int value){
		editer.putInt(key, value);
		editer.commit();
	}
	
	public int getInt(String key){
		return sharedPreferences.getInt(key, 0);
	}
	
	public void putValue(String key, String value){
		editer.putString(key, value);
		editer.commit();
	}
	
	public String getString(String key){
		return sharedPreferences.getString(key, "");
	}
	
	public void putValue(String key, boolean value) {
		editer.putBoolean(key, value);
		editer.commit();
	}
	
	public boolean getBoolean(String key, boolean defValue) {
		return sharedPreferences.getBoolean(key, defValue);
	}
	
	public void remove(String key){
		editer.remove(key);
		editer.commit();
	}
}
